package com.vcredit.creditcat.web;

import com.vcredit.creditcat.framework.pagination.Page;
import com.vcredit.creditcat.model.ChannelCharacter;
import com.vcredit.creditcat.model.RegisterChannel;
import com.vcredit.creditcat.service.ChannelCharacterService;
import com.vcredit.creditcat.service.RegisterChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by liaoshengjun on 2017/11/2.
 */
@Controller
@RequestMapping("/channelCharacter")
public class ChannelCharacterController  extends BaseController {
	@Autowired
	private ChannelCharacterService channelCharacterService;
	@Autowired
	private RegisterChannelService registerChannelService;

	@RequestMapping("/list")
	public ModelAndView showPageUser(HttpServletRequest request) {
		return new ModelAndView("/channelcharacter/channelCharacter");
	}
	@ResponseBody
	@RequestMapping("/listChannelCharacter")
	public Page<ChannelCharacter> findByPage(HttpServletRequest request) {
		return channelCharacterService.findByPage(makeDefaultCriteria(request));
	}
	@ResponseBody
	@RequestMapping("/showAllChannels")
	public List<RegisterChannel> findAllRoles() {
		return registerChannelService.findAll();
	}

	@ResponseBody
	@RequestMapping("/addChannelCharacter")
	public String add(@RequestBody ChannelCharacter channelCharacter, HttpServletRequest request) {
		channelCharacterService.insert(channelCharacter);
		return SUCCESS;
	}

	@ResponseBody
	@RequestMapping("/updateChannelCharacter")
	public String updateShow(@RequestBody ChannelCharacter channelCharacter,HttpServletRequest request) {
		channelCharacterService.update(channelCharacter);
		return SUCCESS;
	}
}
